from django.http import HttpResponse
# from rest_framework.response import Response
from django.http import JsonResponse
from . import similarityApi
import json

def get_similarity(request):
  if request.method == 'GET':
    request.params = request.GET
    return JsonResponse({"status":"ok"})

  elif request.method == 'POST':
    request.params = json.loads(request.body)
    image_path1 = request.params['imagePath1']
    image_path2 = request.params['imagePath2']
    similarity = similarityApi.get_cos_similarity(image_path1, image_path2)
    return JsonResponse({"similarity": similarity})

  # print(request.params)
